<!DOCTYPE html>
<html style="height: 100%">
        {% if warning %}
            <head>
            </head>
            <body>
                <h1>您打印的单据不适用这个打印按钮</h1>

            </body>


        {% else %}
    <head>

        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>出库单打印</title>
        <link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon">
        <link rel="stylesheet" href="/web/static/src/css/full.css">
        <link rel="stylesheet" href="/web/static/lib/fontawesome/css/font-awesome.css">
        <link rel="stylesheet" href="/web/static/lib/bootstrap/css/bootstrap.css">
        <link rel="stylesheet" href="/web/static/src/css/base.css">

        <script src='http://192.168.0.10/CLodopfuncs.js'></script>
        <script language="javascript" src="/lodop/static/src/js/mathlibrary.js"></script>

        <style type="text/css" id="style">
            body{padding: 10px; font-size: 10pt; overflow: auto}

            @media print
            {
                .print-hide {display:none}
            }

            .td_inline {
                display:block;
                overflow:hidden;
                white-space:nowrap;
                text-overflow:ellipsis;
                width: 370pt;
            }

            .nowrap{
                white-space:nowrap;
            }
            /*.table td.noborder{*/
            /*border-top: 0px;*/
            /*}*/

            .table thead tr td{font-weight: bold; font-size: 11pt}

            h4{margin: 0px;  padding: 0px;font-size: 14pt}

            h5{
                font-size:11pt; font-family:'黑体'; font-weight: bold; margin: 0px;  padding: 0px;
            }

            div{font-size: 10pt}

            span.foot_sign{border-bottom: 1px solid #ddd}

            .table tbody tr td{border-top: 1px solid #ddd;}
            .table tbody tr:last-child td{border-top: 1px solid #fff; padding: 0px}
            .table tbody tr.memo td {padding:0px; border-top:0px}

            td{font-size:10pt}

            .font-middle{
                font-size: 12pt;
            }


            .page_head{
                padding-bottom: 20px;
            }

            .underline{text-decoration: underline;}
        </style>
    </head>

    <body>
    <!-- lodop 控制脚本 -->
    <div class="controls controls-row print-hide">
        <script>
        function LICENSES() {
            LODOP.SET_LICENSES("","CD9A14E608164F55F35D564059E8F43B","C94CEE276DB2187AE6B65D56B3FC2848","15F0BE661E7532B77491843CB2ED09AD");
        };

        function print_preview(){
            if (!LODOP.VERSION) return;
            LODOP.PRINT_INIT("东方团购中心出货单{{order.name}}");
    		LODOP.SET_PRINT_PAGESIZE(1, 1910, 2795, "1910x2795");

            var printer_count = LODOP.GET_PRINTER_COUNT();
            var intPrinterIndex = -1;
            for (var i = 0; i < printer_count; i ++){
                if(LODOP.GET_PRINTER_NAME(i).indexOf('东方团购中心出货单') >= 0){
                    intPrinterIndex = i;
                    break;
                }
            }
            if (intPrinterIndex == -1){
                alert('东方团购中心出货单打印机不存在，无法打印');
                return;
            }
            CreateOneFormPage1();
            if (LODOP.SET_PRINTER_INDEXA(intPrinterIndex+'')){
                LODOP.PRINT();
                document.getElementById('btn-print').innerHTML = "已经打印";
                document.getElementById('btn-print').className = "btn btn-primary disabled";
            }
        }
        window.onload = function(){
            LICENSES();
        }

    function CreateOneFormPage1(){
        LODOP.ADD_PRINT_SETUP_BKIMG("<img border='0' src='/dftg_lodop/static/src/img/stock_picking_bg.png'>");
        LODOP.SET_SHOW_MODE("BKIMG_IN_PREVIEW", 1);
{% for move_line in picking.move_lines %}
    {% if loop.index0%10==0 %}
        LODOP.NewPage();
        LODOP.ADD_PRINT_TEXT(270,105,270,16,"{{order.partner_id.name|default('',True)}}");
        LODOP.SET_PRINT_STYLEA(0,"Horient",3);
        LODOP.ADD_PRINT_TEXT(266, 400, 154,30,"{{order.name|default('',True)}}");
        LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
        LODOP.ADD_PRINT_TEXT(294,105,90,16,"{{order.consignee|default(' ',True)}}");
        LODOP.ADD_PRINT_TEXT(294,202,147,16,"{{order.mobile_number|default(' ',True)}} {{order.phone_number|default(' ',True)}}");
        LODOP.ADD_PRINT_TEXT(294,470,152,16,"{{order.date_order|strftime('%Y-%m-%d')|default('',True)}}");
        LODOP.ADD_PRINT_TEXT(317,105,490,16,"{{order.street|default('',True)}}");
        LODOP.ADD_PRINT_TEXT(317,470,100,16,"{{order.expected_delivery_time|default('',True)}} {{ order.expected_delivery_hour }}");
        LODOP.ADD_PRINT_TEXT(18,550,120,15,"第{{ loop.index//10+1 }}页/共{{order.order_line|length//10+1}} 页");
        {% if (order.amount_total|string|reverse)|length>=8 %}
        LODOP.ADD_PRINT_TEXT(593,88,22,16,"{{chinese[(order.amount_total|string|reverse)[8]]}}");
        {% endif %}
        {% if (order.amount_total|string|reverse)|length>=7 %}
        LODOP.ADD_PRINT_TEXT(592,125,18,16,"{{chinese[(order.amount_total|string|reverse)[7]]}}");
        {% endif %}
        {% if (order.amount_total|string|reverse)|length>=6 %}
        LODOP.ADD_PRINT_TEXT(592,159,18,16,"{{chinese[(order.amount_total|string|reverse)[6]]}}");
        {% endif %}
        {% if (order.amount_total|string|reverse)|length>=5%}
        LODOP.ADD_PRINT_TEXT(592,193,19,16,"{{chinese[(order.amount_total|string|reverse)[5]]}}");
        {% endif %}
        {% if (order.amount_total|string|reverse)|length>=4 %}
        LODOP.ADD_PRINT_TEXT(592,226,16,20,"{{chinese[(order.amount_total|string|reverse)[4]]}}");
        {% endif %}
        {% if (order.amount_total|string|reverse)|length>=3 %}
        LODOP.ADD_PRINT_TEXT(592,260,22,16,"{{chinese[(order.amount_total|string|reverse)[3]]}}");
         {% endif %}
        LODOP.ADD_PRINT_TEXT(592,298,18,16,"{{chinese[(order.amount_total|string|reverse)[2]]}}");
        LODOP.ADD_PRINT_TEXT(592,332,21,16,"{{chinese[(order.amount_total|string|reverse)[0]]}}");
        LODOP.ADD_PRINT_TEXT(592,433,120,16,"{{order.amount_total|default('',True)}}");
        //LODOP.ADD_PRINT_TEXT(635,125,270,16,"{{order.phone_number|default(' ',True)}}");
        {% if order.payment_method=='现金' %}
        LODOP.ADD_PRINT_TEXT(615,168,21,16,"{{'√'|string}}");
        {% endif %}
        {% if order.payment_method=='支票' %}
        LODOP.ADD_PRINT_TEXT(615,268,16,20,"{{'√'|string}}");
        {% endif %}
        {% if order.payment_method=='转账' %}
        LODOP.ADD_PRINT_TEXT(615,385,19,16,"{{'√'|string}}");
        {% endif %}
    {% endif%}
    {% if official_invoice_map.get(False) or official_invoice_map.get(True) %}
        //LODOP.ADD_PRINT_TEXT(635,67,478,16,"注：{% if official_invoice_map.get(False) %}开票 {{ official_invoice_map.get(False) }}张{% endif %} {% if official_invoice_map.get(True) %} 开票 {{ official_invoice_map.get(True) }}张(W){% endif %}");
    {% endif %}
    LODOP.ADD_PRINT_TEXT(635,67,478,16,"附带发票: _____张");

    LODOP.ADD_PRINT_TEXT(650,67,478,72,"{{order.note|default(' ',True)|replace('\n', '\\r\\n')}}");
    LODOP.ADD_PRINT_TEXT(868,56,58,16,"{{order.user_id.partner_id.name|default(' ',True)}}");
    //LODOP.ADD_PRINT_TEXT(739,57,478,72,"注：发票"); 移到备注上方

    LODOP.ADD_PRINT_TEXT({{loop.index0 %10 * 22.7+364| round}},21,90,16,"{{move_line.product_id.default_code|default('',True)}}");
    LODOP.ADD_PRINT_TEXT({{loop.index0 %10 * 22.7+364| round}},90,210,16,"{{move_line.product_id.name_template|default('',True)}}");
    LODOP.ADD_PRINT_TEXT({{loop.index0 %10 * 22.7+364| round}},270,65,16,"{{move_line.product_id.prod_model|default('',True)}} {{move_line.prod_spec|default('',True)}} {{move_line.sale_note|default('',True)}}");
    LODOP.ADD_PRINT_TEXT({{loop.index0 %10 * 22.7+364| round}},335,15,16,"{{move_line.product_id.uos_id.name|default(' ',True)}}");
    LODOP.ADD_PRINT_TEXT({{loop.index0 %10 * 22.7+364| round}},345,60,16,"{{price[move_line.product_id.id|string]|default(' ',True)}}");
    LODOP.SET_PRINT_STYLEA(0,"Alignment",3);
    LODOP.ADD_PRINT_TEXT({{loop.index0 %10 * 22.7+364| round}},400,55,16,"{{move_line.product_uom_qty|round|int}}");
    LODOP.SET_PRINT_STYLEA(0,"Alignment",3);
    LODOP.ADD_PRINT_TEXT({{loop.index0 %10 * 22.7+364| round}},453,84,16,"{{price[move_line.product_id.id|string]*move_line.product_uom_qty|round}}");
    LODOP.SET_PRINT_STYLEA(0,"Alignment",3);

{% endfor %}
//LODOP.ADD_PRINT_TEXT(564,62,80,16,"产品编号10");


			LODOP.SET_PRINT_STYLEA(1, "Horient", 3);
		//}

	};

        </script>

        <a id="btn-print" href="javascript:print_preview()" class="btn btn-primary">联单直接打印</a>
        注: 点击按钮打印出库联单，打印A4纸按Ctrl+P键，或者菜单上面选择文件->打印，文件->页面设置里面可以去除页眉页脚

    </div>

    <!-- 出库单据表头 -->
    <div id="div-header">
        <table border="0" cellSpacing="0" cellPadding="0" width="100%">
            <tbody>
                <tr>
                    <td align="center">
                        <h4 class="page_head">{{ order.company_id.name}}{% if picking.picking_type_code=='incoming' %}入库单{% else %}出货单 {% endif %}</h4>
                    </td>
                </tr>
				{% if picking.picking_type_code!='incoming' %}
                <tr>
                    <td>
                        客户:<span style="font-size: 11pt">
                        {% if order.partner_id.is_company %}
                            {{ order.partner_id.name|default('', True) }}
                        {% else %}
                            {{ order.partner_id.name|default('', True) }}
                        {% endif %}
                    </span>
                    </td>
                </tr>
                <tr>

                    <td>收货地址:
						{% if order.province_id and order.province_id.name != '上海市' %}
						{{order.province_id.name}}
						{% endif %}
						 &nbsp;
						{% if order.city_id %}
						{{order.city_id.city_name}}
						{% endif %}
						 &nbsp;
						{% if order.county_id %}
						{{order.county_id.county_name}}
						{% endif %}
						 &nbsp;
							{% if order.street %}
						{{order.street}}
						{% endif %}
                        &nbsp;&nbsp;
						收货人:&nbsp;{{order.consignee}}
                        {% if order.mobile_number %}
                            &nbsp;&nbsp;
                            手机:{{ order.mobile_number|default('', True) }}
                        {% endif %}
						 {% if order.phone_number %}
                        电话:{{ order.phone_number|default('', True)}}
						  {% endif %}

                    </td>
					{% endif %}
                </tr>
            </tbody>
        </table>
    </div>

    <!-- 出库单据表身 -->
    <div id="div-body">
        <table class="table table-striped" width="100%">
            <thead>
            <tr>
                <td width="55">序号</td>
                <td class="nowrap" style="text-align: left;">产品名称</td>
                <td class="nowrap" style="text-align: left;">产品型号说明</td>
                <td class="nowrap" style="text-align: right;">数量</td>
            </tr>
            </thead>
            <tbody>
            {% for line in picking.move_lines %}
            <tr>
                <td>{{loop.index}}</td>
                <td style="text-align: left;">
                    <span>{{ line.product_id.name_template|default('', True) }}</span>
                </td>
                <td style="text-align: left;">{{line.product_id.prod_model|default('',True)}} {{line.prod_spec|default('',True)}} {{line.sale_note|default('',True)}}</td>
                <td style="text-align: right;">{{ line.product_uom_qty| int() }}{% if line.product_id.is_card %}(张) {% else %}(件){% endif %}</td>
            </tr>
            {% endfor %}

            <tr>
                <td colspan="8" style="text-align: left;border-top: 1px solid #ddd;">
                   备注：
                </td>
            </tr>
            {% if official_invoice_map.get(False) or official_invoice_map.get(True) %}
            <tr><td colspan="8">
                <!--{% if official_invoice_map.get(False) %}开票:{{official_invoice_map.get(False)}}张{% endif %}
                {% if official_invoice_map.get(True) %}开票:{{official_invoice_map.get(True)}}张(W){% endif %}-->
                附带发票: _____张
            </td></tr>
            {% endif %}
            {% if order.note %}
                {% for line in order.note.split('\n') %}
            <tr class="memo">
                <td colspan="8">
                    {{ line }}
                </td>
            </tr>
                {% endfor %}
            {% endif %}
            </tbody>
        </table>
    </div>
    </body>
        {% endif %}
</html>
